import type { UserDept } from '@/api/modules/system/user/types';
import { deptTree } from '@/api/modules/system/user/user';

export const deptTreeData = ref<UserDept[]>([]);
/* 根据用户获取对应部门 */
export const getDeptTree = async (): Promise<UserDept[]> => {
  if (deptTreeData.value.length === 0) {
    const { data } = await deptTree();
    if (data.data) {
      deptTreeData.value = data.data;
      return data.data;
    }
  }
  return deptTreeData.value;
};
